﻿using System;
using System.Threading;

namespace Development.Tools
{
    /// <summary>
    /// 线程工具
    /// </summary>
    public class ThreadUtils
    {
        public static void WaitTrue(ref bool isTrue)
        {
            while(!isTrue)
            {
                Thread.Sleep(20);
            }
        }

        public static void WaitTrue(ref bool isTrue,TimeSpan outTime)
        {
            DateTime start = DateTime.Now;
            while (!isTrue)
            {
                Thread.Sleep(20);
                if((DateTime.Now - start)>= outTime)
                {
                    break;
                }
            }
        }

        public static void Sleep(int ms)
        {
            Thread.Sleep(ms);
        }
    }
}
